<html>
<head></head>
<body>
<?php
@$name=$_REQUEST['name'];
@$pwd=$_REQUEST['password'];
$str="mysql:dbname=test;";
$pdo=new PDO($str,'root');
$result=$pdo->prepare('select * from user where name=:name and password=:pwd');
$result->execute(array('name'=>$name,'pwd'=>$pwd));
$line=$result->fetch();
print_r(' ');
session_start();
$_SESSION['name']=$line::name;
?>
<form method="post">
用户名:<input type="text" name="name">
密码:<input type="password" name="password">
<input type="submit" value="登录">
</form>
</body>
</html>